package org.emet.jee;

import java.util.ResourceBundle;

import org.apache.commons.lang.StringUtils;

import flex.messaging.MessageException;

/**
 * Service层公用的Exception.
 * 
 * 继承自RuntimeException, 从由Spring管理事务的函数中抛出时会触发事务回滚.
 * 
 */
public class BusinessException extends MessageException {

	private static final long serialVersionUID = 3583566093089790852L;

	private static final ResourceBundle RES_BOUNDLE = ResourceBundle.getBundle("applicationResource");

	public BusinessException() {
		super();
	}

	public BusinessException(String info) {
		String message = null;
		try {
			message = RES_BOUNDLE.getString(info);
		} catch (Exception e) {

		}
		if (StringUtils.isBlank(message)) {
			message = info;
		}
		setMessage(message);
	}

	public BusinessException(Throwable cause) {
		super(cause);
	}

	public BusinessException(String message, Throwable cause) {
		this(message);
		setRootCause(cause);
	}
}
